package cn.edu.scujcc;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/comment")
public class CommentController {
		
	
	@Autowired
	private CommentService service;
	
	
	@GetMapping("/hot")
	public List<Comment> getHotComment(){
		List<Comment>result = null;
		result = service.getHotComments();
		return result;
		}
	
	
	@GetMapping("/All")
	public List<Comment> getAllComments(){
		List<Comment>result = null;
		result = service.getAllComments();
		return result;
	}
	
	
	@PostMapping
	public Comment newComment(@RequestBody Comment c) {
	Comment result = null;
	result = service.newComment(c);
	return result;
	}
	
	
	@PutMapping("/up/{id}")
	public Comment upComment(@PathVariable String id) {
	Comment result = null;
	result = service.upComment(id);
	return result;
	}
	
	
	@DeleteMapping("/del/{id}")
	public boolean deleteComment(@PathVariable String id) {
	boolean result = false;
	result = service.delComment(id);
	return result;
	}
	
	
}
